﻿using AutoMapper;
using MediatR;
using StoreIModels;
using StoreISet.Applicationes.Command;
using StoreRepositorys.Interface;
using System.Net.Http.Headers;

namespace StoreISet.Applicationes.CommandHandler
{
    public class StorelStateCommandHandler : IRequestHandler<StorelStateCommand, int>
    {
        public IStoreRepository _IRepository;
        public IMapper _mapper;
        public StorelStateCommandHandler (IStoreRepository repository,IMapper mapper)
        {
            _IRepository = repository;
            _mapper = mapper;
        }

        public async Task<int> Handle(StorelStateCommand request, CancellationToken cancellationToken)
        
        {

            
            var list = await _IRepository.GetModelasync(request.id);
            list.StoreState = request.state;
            var res=await _IRepository.Updateasync(list);
            return res;
        }
    }
}
